//
//  NoteCommentCell.m
//  DogeLegs
//
//  Created by 宋华 on 2017/8/22.
//  Copyright © 2017年 宋华. All rights reserved.
//

#import "NoteCommentCell.h"

@interface NoteCommentCell () {


}
@property (weak, nonatomic) IBOutlet UIImageView *userIconImageView;

@property (weak, nonatomic) IBOutlet UILabel *userNamelabel;

@property (weak, nonatomic) IBOutlet UILabel *commentContentLabel;

@property (weak, nonatomic) IBOutlet UILabel *commentDateLabel;

@end

@implementation NoteCommentCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)cellWillDisplay:(NoteCommentMode *)comMode {
    [self.userIconImageView sd_setImageWithURL:[NSURL URLWithString:comMode.user.headPortraitUrl] placeholderImage:[UIImage imageNamed:@"photo"]];
    self.userNamelabel.text  = comMode.user.userName;
    if (comMode.toUser) {
        NSString *com = comMode.comContentStr;
         NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:com];
         [str addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0,comMode.toUser.userName.length)]; //设置字体颜色
        self.commentContentLabel.attributedText = str;
    } else {
        self.commentContentLabel.text = comMode.commentContent;
    }
    
    self.commentDateLabel.text = comMode.commentDateStr;
}

+ (CGFloat)commentCellHeight:(NoteCommentMode *)comMode {
    CGFloat totalHeight = 48;//固定大小
    totalHeight += [comMode.comContentStr sizeWithFont:[UIFont systemFontOfSize:13] maxSize:CGSizeMake(kScreenWidth - 60, 100000)].height;
    return totalHeight;
}

@end
